/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MainPanel.java
 *
 * Created on Oct 27, 2012, 11:16:44 PM
 */
package iapractica.views;

import com.frre.cemami.utils.MathUtils;
import genetics.productos.exceptions.NoMateriaPrimaAddedException;
import iapractica.controllers.MainPanelController;
import iapractica.views.popups.PopUpFactory;
import java.awt.Component;
import java.util.LinkedList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;

/**
 *
 * @author Justo Vargas
 */
public class MainPanelView extends GenericView {

    private XYSeriesCollection xySeriesCollection;
    private ChartPanel myChartPanel;
    private LinkedList<JSpinner> spinnersCargaDatos = new LinkedList<JSpinner>();
    private XYPlot xyPlot;
    private JFreeChart jfreechart;
    int iteracionesMaxima;
    double worstAptitudNumber = 0;

    /** Creates new form MainPanel */
    public MainPanelView() {
        initComponents();
        makeJFreChartPanel();

        init();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        tabPanel = new javax.swing.JTabbedPane();
        cargaDatos = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jSpinner1 = new javax.swing.JSpinner();
        jSpinner2 = new javax.swing.JSpinner();
        jLabel5 = new javax.swing.JLabel();
        jSpinner3 = new javax.swing.JSpinner();
        jLabel6 = new javax.swing.JLabel();
        jSpinner4 = new javax.swing.JSpinner();
        jLabel7 = new javax.swing.JLabel();
        jSpinner5 = new javax.swing.JSpinner();
        jLabel8 = new javax.swing.JLabel();
        jSpinner6 = new javax.swing.JSpinner();
        jLabel9 = new javax.swing.JLabel();
        jSpinner7 = new javax.swing.JSpinner();
        jLabel10 = new javax.swing.JLabel();
        jSpinner8 = new javax.swing.JSpinner();
        jLabel11 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        indivMax1 = new javax.swing.JSpinner();
        iteracionesMax1 = new javax.swing.JSpinner();
        operadoresGeneticos = new javax.swing.JPanel();
        jPanel11 = new javax.swing.JPanel();
        Metodos = new javax.swing.JPanel();
        jCheckBox1 = new javax.swing.JCheckBox();
        jCheckBox2 = new javax.swing.JCheckBox();
        jCheckBox6 = new javax.swing.JCheckBox();
        jCheckBox8 = new javax.swing.JCheckBox();
        jLabel12 = new javax.swing.JLabel();
        jSpinner13 = new javax.swing.JSpinner();
        jPanel12 = new javax.swing.JPanel();
        Metodos1 = new javax.swing.JPanel();
        jCheckBox3 = new javax.swing.JCheckBox();
        jCheckBox4 = new javax.swing.JCheckBox();
        jCheckBox9 = new javax.swing.JCheckBox();
        jLabel13 = new javax.swing.JLabel();
        jSpinner12 = new javax.swing.JSpinner();
        jPanel13 = new javax.swing.JPanel();
        Metodos2 = new javax.swing.JPanel();
        jCheckBox5 = new javax.swing.JCheckBox();
        jCheckBox7 = new javax.swing.JCheckBox();
        jCheckBox10 = new javax.swing.JCheckBox();
        jLabel14 = new javax.swing.JLabel();
        jSpinner11 = new javax.swing.JSpinner();
        jPanel6 = new javax.swing.JPanel();
        jPanel5 = new javax.swing.JPanel();
        velocidad = new javax.swing.JSlider();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jButton6 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        useChart = new javax.swing.JCheckBox();
        stadistic = new javax.swing.JPanel();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        statics = new javax.swing.JCheckBox();
        bestAptitud = new javax.swing.JLabel();
        worstAptitud = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        averageAptitud = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        population = new javax.swing.JLabel();
        jLabel25 = new javax.swing.JLabel();
        age = new javax.swing.JLabel();
        jPanel7 = new javax.swing.JPanel();
        jProgressBar1 = new javax.swing.JProgressBar();
        chartPanel = new javax.swing.JPanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(iapractica.IAPracticaApp.class).getContext().getResourceMap(MainPanelView.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setName("Form"); // NOI18N
        setResizable(false);
        getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.LINE_AXIS));

        jPanel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jPanel1.setName("jPanel1"); // NOI18N
        jPanel1.setLayout(new javax.swing.BoxLayout(jPanel1, javax.swing.BoxLayout.LINE_AXIS));

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, resourceMap.getString("jPanel2.border.title"), javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.TOP)); // NOI18N
        jPanel2.setAutoscrolls(true);
        jPanel2.setName("jPanel2"); // NOI18N
        jPanel2.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel3.border.title"))); // NOI18N
        jPanel3.setName("jPanel3"); // NOI18N

        tabPanel.setTabLayoutPolicy(javax.swing.JTabbedPane.SCROLL_TAB_LAYOUT);
        tabPanel.setAutoscrolls(true);
        tabPanel.setName("tabPanel"); // NOI18N

        cargaDatos.setName("cargaDatos"); // NOI18N
        cargaDatos.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N
        cargaDatos.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 11, -1, -1));

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N
        cargaDatos.add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 40, 20, 20));

        jSpinner1.setName("jSpinner1"); // NOI18N
        cargaDatos.add(jSpinner1, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 40, 60, -1));

        jSpinner2.setName("jSpinner2"); // NOI18N
        cargaDatos.add(jSpinner2, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 70, 60, -1));

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N
        cargaDatos.add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 70, 20, 20));

        jSpinner3.setName("jSpinner3"); // NOI18N
        cargaDatos.add(jSpinner3, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 100, 60, -1));

        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N
        cargaDatos.add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 100, 20, 20));

        jSpinner4.setName("jSpinner4"); // NOI18N
        cargaDatos.add(jSpinner4, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 130, 60, -1));

        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N
        cargaDatos.add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 130, 20, 20));

        jSpinner5.setName("jSpinner5"); // NOI18N
        cargaDatos.add(jSpinner5, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 40, 60, -1));

        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N
        cargaDatos.add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 130, 20, 20));

        jSpinner6.setName("jSpinner6"); // NOI18N
        cargaDatos.add(jSpinner6, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 70, 60, -1));

        jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
        jLabel9.setName("jLabel9"); // NOI18N
        cargaDatos.add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 40, 20, 20));

        jSpinner7.setName("jSpinner7"); // NOI18N
        cargaDatos.add(jSpinner7, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 100, 60, -1));

        jLabel10.setText(resourceMap.getString("jLabel10.text")); // NOI18N
        jLabel10.setName("jLabel10"); // NOI18N
        cargaDatos.add(jLabel10, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 70, 20, 20));

        jSpinner8.setName("jSpinner8"); // NOI18N
        cargaDatos.add(jSpinner8, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 130, 60, -1));

        jLabel11.setText(resourceMap.getString("jLabel11.text")); // NOI18N
        jLabel11.setName("jLabel11"); // NOI18N
        cargaDatos.add(jLabel11, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 100, 20, 20));

        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
        jButton1.setName("jButton1"); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        cargaDatos.add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(470, 140, -1, 30));

        jButton2.setText(resourceMap.getString("jButton2.text")); // NOI18N
        jButton2.setName("jButton2"); // NOI18N
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        cargaDatos.add(jButton2, new org.netbeans.lib.awtextra.AbsoluteConstraints(640, 140, 160, 30));

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N
        cargaDatos.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 70, -1, -1));

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N
        cargaDatos.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 40, -1, -1));

        indivMax1.setName("indivMax1"); // NOI18N
        cargaDatos.add(indivMax1, new org.netbeans.lib.awtextra.AbsoluteConstraints(390, 70, 100, -1));

        iteracionesMax1.setName("iteracionesMax1"); // NOI18N
        cargaDatos.add(iteracionesMax1, new org.netbeans.lib.awtextra.AbsoluteConstraints(390, 40, 100, -1));

        tabPanel.addTab("Carga de Datos", cargaDatos);

        operadoresGeneticos.setName("operadoresGeneticos"); // NOI18N
        operadoresGeneticos.setLayout(new javax.swing.BoxLayout(operadoresGeneticos, javax.swing.BoxLayout.LINE_AXIS));

        jPanel11.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel11.border.title"))); // NOI18N
        jPanel11.setName("jPanel11"); // NOI18N

        Metodos.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("Metodos.border.title"))); // NOI18N
        Metodos.setName("Metodos"); // NOI18N

        jCheckBox1.setText(resourceMap.getString("jCheckBox1.text")); // NOI18N
        jCheckBox1.setName("jCheckBox1"); // NOI18N

        jCheckBox2.setText(resourceMap.getString("jCheckBox2.text")); // NOI18N
        jCheckBox2.setName("jCheckBox2"); // NOI18N

        jCheckBox6.setText(resourceMap.getString("jCheckBox6.text")); // NOI18N
        jCheckBox6.setName("jCheckBox6"); // NOI18N

        javax.swing.GroupLayout MetodosLayout = new javax.swing.GroupLayout(Metodos);
        Metodos.setLayout(MetodosLayout);
        MetodosLayout.setHorizontalGroup(
            MetodosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(MetodosLayout.createSequentialGroup()
                .addGap(28, 28, 28)
                .addGroup(MetodosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jCheckBox6)
                    .addComponent(jCheckBox2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jCheckBox1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(80, Short.MAX_VALUE))
        );
        MetodosLayout.setVerticalGroup(
            MetodosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(MetodosLayout.createSequentialGroup()
                .addComponent(jCheckBox1)
                .addGap(3, 3, 3)
                .addComponent(jCheckBox2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jCheckBox6)
                .addContainerGap())
        );

        jCheckBox8.setText(resourceMap.getString("jCheckBox8.text")); // NOI18N
        jCheckBox8.setName("jCheckBox8"); // NOI18N

        jLabel12.setText(resourceMap.getString("jLabel12.text")); // NOI18N
        jLabel12.setName("jLabel12"); // NOI18N

        jSpinner13.setName("jSpinner13"); // NOI18N

        javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11);
        jPanel11.setLayout(jPanel11Layout);
        jPanel11Layout.setHorizontalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(Metodos, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jCheckBox8, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel12)
                    .addComponent(jSpinner13, javax.swing.GroupLayout.DEFAULT_SIZE, 249, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel11Layout.setVerticalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel11Layout.createSequentialGroup()
                .addComponent(jCheckBox8)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel12)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSpinner13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 10, Short.MAX_VALUE)
                .addComponent(Metodos, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        operadoresGeneticos.add(jPanel11);

        jPanel12.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel12.border.title"))); // NOI18N
        jPanel12.setName("jPanel12"); // NOI18N

        Metodos1.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("Metodos1.border.title"))); // NOI18N
        Metodos1.setName("Metodos1"); // NOI18N

        jCheckBox3.setText(resourceMap.getString("jCheckBox3.text")); // NOI18N
        jCheckBox3.setName("jCheckBox3"); // NOI18N

        jCheckBox4.setText(resourceMap.getString("jCheckBox4.text")); // NOI18N
        jCheckBox4.setName("jCheckBox4"); // NOI18N

        javax.swing.GroupLayout Metodos1Layout = new javax.swing.GroupLayout(Metodos1);
        Metodos1.setLayout(Metodos1Layout);
        Metodos1Layout.setHorizontalGroup(
            Metodos1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(Metodos1Layout.createSequentialGroup()
                .addGap(33, 33, 33)
                .addGroup(Metodos1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jCheckBox3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jCheckBox4, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(81, Short.MAX_VALUE))
        );
        Metodos1Layout.setVerticalGroup(
            Metodos1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(Metodos1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jCheckBox3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jCheckBox4)
                .addContainerGap(19, Short.MAX_VALUE))
        );

        jCheckBox9.setText(resourceMap.getString("jCheckBox9.text")); // NOI18N
        jCheckBox9.setName("jCheckBox9"); // NOI18N

        jLabel13.setText(resourceMap.getString("jLabel13.text")); // NOI18N
        jLabel13.setName("jLabel13"); // NOI18N

        jSpinner12.setName("jSpinner12"); // NOI18N

        javax.swing.GroupLayout jPanel12Layout = new javax.swing.GroupLayout(jPanel12);
        jPanel12.setLayout(jPanel12Layout);
        jPanel12Layout.setHorizontalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel12Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel12Layout.createSequentialGroup()
                        .addComponent(Metodos1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addContainerGap())
                    .addComponent(jCheckBox9, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel12Layout.createSequentialGroup()
                        .addComponent(jLabel13)
                        .addContainerGap(134, Short.MAX_VALUE))
                    .addGroup(jPanel12Layout.createSequentialGroup()
                        .addComponent(jSpinner12, javax.swing.GroupLayout.DEFAULT_SIZE, 234, Short.MAX_VALUE)
                        .addGap(9, 9, 9))))
        );
        jPanel12Layout.setVerticalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel12Layout.createSequentialGroup()
                .addComponent(jCheckBox9)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel13)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jSpinner12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(Metodos1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        operadoresGeneticos.add(jPanel12);

        jPanel13.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel13.border.title"))); // NOI18N
        jPanel13.setName("jPanel13"); // NOI18N

        Metodos2.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("Metodos2.border.title"))); // NOI18N
        Metodos2.setName("Metodos2"); // NOI18N

        jCheckBox5.setText(resourceMap.getString("jCheckBox5.text")); // NOI18N
        jCheckBox5.setName("jCheckBox5"); // NOI18N

        jCheckBox7.setText(resourceMap.getString("jCheckBox7.text")); // NOI18N
        jCheckBox7.setName("jCheckBox7"); // NOI18N

        javax.swing.GroupLayout Metodos2Layout = new javax.swing.GroupLayout(Metodos2);
        Metodos2.setLayout(Metodos2Layout);
        Metodos2Layout.setHorizontalGroup(
            Metodos2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(Metodos2Layout.createSequentialGroup()
                .addGap(34, 34, 34)
                .addGroup(Metodos2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jCheckBox7)
                    .addComponent(jCheckBox5))
                .addContainerGap(81, Short.MAX_VALUE))
        );
        Metodos2Layout.setVerticalGroup(
            Metodos2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(Metodos2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jCheckBox5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jCheckBox7)
                .addContainerGap(23, Short.MAX_VALUE))
        );

        jCheckBox10.setText(resourceMap.getString("jCheckBox10.text")); // NOI18N
        jCheckBox10.setName("jCheckBox10"); // NOI18N

        jLabel14.setText(resourceMap.getString("jLabel14.text")); // NOI18N
        jLabel14.setName("jLabel14"); // NOI18N

        jSpinner11.setName("jSpinner11"); // NOI18N

        javax.swing.GroupLayout jPanel13Layout = new javax.swing.GroupLayout(jPanel13);
        jPanel13.setLayout(jPanel13Layout);
        jPanel13Layout.setHorizontalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel13Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(Metodos2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jCheckBox10, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel14)
                    .addComponent(jSpinner11, javax.swing.GroupLayout.DEFAULT_SIZE, 234, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel13Layout.setVerticalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel13Layout.createSequentialGroup()
                .addComponent(jCheckBox10)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel14)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSpinner11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(Metodos2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        operadoresGeneticos.add(jPanel13);

        tabPanel.addTab("Ajuste de Operadores Geneticos", operadoresGeneticos);

        jPanel6.setName("jPanel6"); // NOI18N
        jPanel6.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel5.border.title"))); // NOI18N
        jPanel5.setName("jPanel5"); // NOI18N
        jPanel5.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        velocidad.setPaintLabels(true);
        velocidad.setPaintTicks(true);
        velocidad.setSnapToTicks(true);
        velocidad.setValue(100);
        velocidad.setName("velocidad"); // NOI18N
        velocidad.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                velocidadStateChanged(evt);
            }
        });
        velocidad.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                velocidadPropertyChange(evt);
            }
        });
        jPanel5.add(velocidad, new org.netbeans.lib.awtextra.AbsoluteConstraints(6, 16, 558, -1));

        jLabel19.setForeground(resourceMap.getColor("jLabel19.foreground")); // NOI18N
        jLabel19.setText(resourceMap.getString("jLabel19.text")); // NOI18N
        jLabel19.setName("jLabel19"); // NOI18N
        jPanel5.add(jLabel19, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 45, -1, -1));

        jLabel20.setForeground(resourceMap.getColor("jLabel20.foreground")); // NOI18N
        jLabel20.setText(resourceMap.getString("jLabel20.text")); // NOI18N
        jLabel20.setName("jLabel20"); // NOI18N
        jPanel5.add(jLabel20, new org.netbeans.lib.awtextra.AbsoluteConstraints(540, 45, -1, -1));

        jPanel6.add(jPanel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 60, 570, 70));

        jPanel4.setName("jPanel4"); // NOI18N
        jPanel4.setLayout(new java.awt.GridLayout(1, 0));

        jButton6.setText(resourceMap.getString("jButton6.text")); // NOI18N
        jButton6.setName("jButton6"); // NOI18N
        jPanel4.add(jButton6);

        jButton5.setText(resourceMap.getString("jButton5.text")); // NOI18N
        jButton5.setName("jButton5"); // NOI18N
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });
        jPanel4.add(jButton5);

        jButton4.setText(resourceMap.getString("jButton4.text")); // NOI18N
        jButton4.setName("jButton4"); // NOI18N
        jPanel4.add(jButton4);

        jButton3.setText(resourceMap.getString("jButton3.text")); // NOI18N
        jButton3.setName("jButton3"); // NOI18N
        jPanel4.add(jButton3);

        jPanel6.add(jPanel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(15, 10, 560, 40));

        useChart.setText(resourceMap.getString("useChart.text")); // NOI18N
        useChart.setName("useChart"); // NOI18N
        useChart.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                useChartItemStateChanged(evt);
            }
        });
        useChart.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                useChartActionPerformed(evt);
            }
        });
        jPanel6.add(useChart, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 180, 240, -1));

        stadistic.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("stadistic.border.title"))); // NOI18N
        stadistic.setName("stadistic"); // NOI18N
        stadistic.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel17.setText(resourceMap.getString("jLabel17.text")); // NOI18N
        jLabel17.setName("jLabel17"); // NOI18N
        stadistic.add(jLabel17, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 40, -1, -1));

        jLabel18.setText(resourceMap.getString("jLabel18.text")); // NOI18N
        jLabel18.setName("jLabel18"); // NOI18N
        stadistic.add(jLabel18, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 66, -1, -1));

        statics.setText(resourceMap.getString("statics.text")); // NOI18N
        statics.setName("statics"); // NOI18N
        statics.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                staticsItemStateChanged(evt);
            }
        });
        statics.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                staticsActionPerformed(evt);
            }
        });
        stadistic.add(statics, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 10, -1, -1));

        bestAptitud.setText(resourceMap.getString("bestAptitud.text")); // NOI18N
        bestAptitud.setName("bestAptitud"); // NOI18N
        stadistic.add(bestAptitud, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 40, -1, -1));

        worstAptitud.setText(resourceMap.getString("worstAptitud.text")); // NOI18N
        worstAptitud.setName("worstAptitud"); // NOI18N
        stadistic.add(worstAptitud, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 66, -1, -1));

        jLabel21.setText(resourceMap.getString("jLabel21.text")); // NOI18N
        jLabel21.setName("jLabel21"); // NOI18N
        stadistic.add(jLabel21, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 90, -1, -1));

        averageAptitud.setText(resourceMap.getString("averageAptitud.text")); // NOI18N
        averageAptitud.setName("averageAptitud"); // NOI18N
        stadistic.add(averageAptitud, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 90, -1, -1));

        jLabel23.setText(resourceMap.getString("jLabel23.text")); // NOI18N
        jLabel23.setName("jLabel23"); // NOI18N
        stadistic.add(jLabel23, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 115, -1, -1));

        population.setText(resourceMap.getString("population.text")); // NOI18N
        population.setName("population"); // NOI18N
        stadistic.add(population, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 115, -1, -1));

        jLabel25.setText(resourceMap.getString("jLabel25.text")); // NOI18N
        jLabel25.setName("jLabel25"); // NOI18N
        stadistic.add(jLabel25, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 140, -1, -1));

        age.setText(resourceMap.getString("age.text")); // NOI18N
        age.setName("age"); // NOI18N
        stadistic.add(age, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 140, -1, -1));

        jPanel6.add(stadistic, new org.netbeans.lib.awtextra.AbsoluteConstraints(590, 10, 212, 180));

        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel7.border.title"))); // NOI18N
        jPanel7.setName("jPanel7"); // NOI18N
        jPanel7.setLayout(new java.awt.GridLayout());

        jProgressBar1.setName("jProgressBar1"); // NOI18N
        jPanel7.add(jProgressBar1);

        jPanel6.add(jPanel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 130, 570, 50));

        tabPanel.addTab("Propiedades Simulacion", jPanel6);

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(tabPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 818, Short.MAX_VALUE)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addComponent(tabPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 236, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel2.add(jPanel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(6, 16, 830, 270));

        chartPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("chartPanel.border.title"))); // NOI18N
        chartPanel.setAutoscrolls(true);
        chartPanel.setName("chartPanel"); // NOI18N
        chartPanel.setLayout(new javax.swing.BoxLayout(chartPanel, javax.swing.BoxLayout.LINE_AXIS));
        jPanel2.add(chartPanel, new org.netbeans.lib.awtextra.AbsoluteConstraints(6, 288, 824, 280));

        jPanel1.add(jPanel2);

        getContentPane().add(jPanel1);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        for (JSpinner jSpinner : spinnersCargaDatos) {
            Integer number = (int) MathUtils.getRandomNumber(0, 1000);
            jSpinner.setValue(number);
        }
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
        int[] valores = new int[8];
        for (JSpinner jSpinner : spinnersCargaDatos) {
            try {
                if (jSpinner.getName().startsWith("j")) {
                    int value = Integer.parseInt(jSpinner.getValue().toString());
                    String name = jSpinner.getName().substring(jSpinner.getName().length() - 1);
                    int pos = Integer.parseInt(name);
                    valores[pos - 1] = value;
                }
            } catch (NumberFormatException e) {
                PopUpFactory.showErrorPopUP(this, "Los Campos deben ser solamente numeros");
                return;
            }
        }
        MainPanelController main = (MainPanelController) this.getController();
        main.addMateriaPrima(valores);

        main.setMaximumPopulation(Integer.parseInt(indivMax1.getValue().toString()));
        iteracionesMaxima = Integer.parseInt(iteracionesMax1.getValue().toString());
        main.setMaximumAge(iteracionesMaxima);
        PopUpFactory.showConfirmPopUP(this, "Valores Agregados con exito");
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        // TODO add your handling code here:
        MainPanelController main = (MainPanelController) this.getController();
        try {
            main.startSimulation();
        } catch (NoMateriaPrimaAddedException ex) {
            PopUpFactory.showErrorPopUP(this, "No agresgaste materia prima para comenzar con la simulacion");
        }
    }//GEN-LAST:event_jButton5ActionPerformed

    private void useChartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_useChartActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_useChartActionPerformed

    private void staticsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_staticsActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_staticsActionPerformed

    private void staticsItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_staticsItemStateChanged
        // TODO add your handling code here:
        enableStadistics();
    }//GEN-LAST:event_staticsItemStateChanged

    private void useChartItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_useChartItemStateChanged
        // TODO add your handling code here:
        boolean value = useChart.isSelected();
        chartPanel.setEnabled(value);
        jfreechart.setNotify(value);
        this.chartPanel.setEnabled(value);
    }//GEN-LAST:event_useChartItemStateChanged

    private void velocidadPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_velocidadPropertyChange
        // TODO add your handling code here:
     
       

    }//GEN-LAST:event_velocidadPropertyChange

    private void velocidadStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_velocidadStateChanged
        // TODO add your handling code here:
         MainPanelController main = (MainPanelController) this.getController();
        if (main != null){
            main.setSimulationVelocity(this.velocidad.getValue());
        }
    }//GEN-LAST:event_velocidadStateChanged

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new MainPanelView().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel Metodos;
    private javax.swing.JPanel Metodos1;
    private javax.swing.JPanel Metodos2;
    private javax.swing.JLabel age;
    private javax.swing.JLabel averageAptitud;
    private javax.swing.JLabel bestAptitud;
    private javax.swing.JPanel cargaDatos;
    private javax.swing.JPanel chartPanel;
    private javax.swing.JSpinner indivMax1;
    private javax.swing.JSpinner iteracionesMax1;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JCheckBox jCheckBox1;
    private javax.swing.JCheckBox jCheckBox10;
    private javax.swing.JCheckBox jCheckBox2;
    private javax.swing.JCheckBox jCheckBox3;
    private javax.swing.JCheckBox jCheckBox4;
    private javax.swing.JCheckBox jCheckBox5;
    private javax.swing.JCheckBox jCheckBox6;
    private javax.swing.JCheckBox jCheckBox7;
    private javax.swing.JCheckBox jCheckBox8;
    private javax.swing.JCheckBox jCheckBox9;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel12;
    private javax.swing.JPanel jPanel13;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JProgressBar jProgressBar1;
    private javax.swing.JSpinner jSpinner1;
    private javax.swing.JSpinner jSpinner11;
    private javax.swing.JSpinner jSpinner12;
    private javax.swing.JSpinner jSpinner13;
    private javax.swing.JSpinner jSpinner2;
    private javax.swing.JSpinner jSpinner3;
    private javax.swing.JSpinner jSpinner4;
    private javax.swing.JSpinner jSpinner5;
    private javax.swing.JSpinner jSpinner6;
    private javax.swing.JSpinner jSpinner7;
    private javax.swing.JSpinner jSpinner8;
    private javax.swing.JPanel operadoresGeneticos;
    private javax.swing.JLabel population;
    private javax.swing.JPanel stadistic;
    private javax.swing.JCheckBox statics;
    private javax.swing.JTabbedPane tabPanel;
    private javax.swing.JCheckBox useChart;
    private javax.swing.JSlider velocidad;
    private javax.swing.JLabel worstAptitud;
    // End of variables declaration//GEN-END:variables

    public JPanel getChartPanel() {
        return chartPanel;
    }

    public void addPanel(JPanel panel) {
        this.chartPanel.add(panel);
        this.pack();
    }

    @Override
    public void reset() {
    }

    private void makeJFreChartPanel() {
        myChartPanel = createChartPanel();
        this.chartPanel.add(myChartPanel);
    }

    private ChartPanel createChartPanel() {
        jfreechart = ChartFactory.createScatterPlot(
                "Poblacion", "Individuos", "Fitness Value", createSampleData(),
                PlotOrientation.VERTICAL, true, true, false);
        xyPlot = (XYPlot) jfreechart.getPlot();
        xyPlot.setDomainCrosshairVisible(true);
        xyPlot.setRangeCrosshairVisible(true);
        NumberAxis domain = (NumberAxis) xyPlot.getDomainAxis();
        domain.setVerticalTickLabels(true);
        return new ChartPanel(jfreechart);
    }

    private XYDataset createSampleData() {
        xySeriesCollection = new XYSeriesCollection();
        return xySeriesCollection;
    }

    public void updateChart(Double average, int age, LinkedList<Double> data) {
        try {
            if (statics.isSelected()) {
                this.bestAptitud.setText(data.get(0).toString());
                Double localWorst = data.get(data.size() - 1);
                if (localWorst > worstAptitudNumber) {
                    this.worstAptitud.setText(localWorst.toString());
                    worstAptitudNumber = localWorst;
                }
                String promedio = average.toString();
                int hasDot = promedio.indexOf(".");
                if ((hasDot > 0) && (promedio.length() > hasDot + 3)) {
                    promedio = promedio.substring(0, hasDot + 3);
                }
                this.averageAptitud.setText(promedio);
                this.population.setText(String.valueOf(data.size()));
                this.age.setText(age + "/" + iteracionesMaxima);
            }
            if (useChart.isSelected()) {
                if (xySeriesCollection.getSeriesCount() > 3) {
                    xySeriesCollection.removeSeries(0);
                }
                XYSeries series = new XYSeries("Age " + age);
                for (int i = 0; i < data.size(); i++) {
                    Double myData = data.get(i);
                    double x = i;
                    double y = myData;
                    series.add(x, y);
                }
                xySeriesCollection.addSeries(series);
            }
        } catch (Exception e) {
            logguer.logError(e.getClass(), e.getMessage());
        }
    }

    private void init() {
        //set tab titles
        this.tabPanel.setTitleAt(0, "Carga de Datos");
        this.tabPanel.setTitleAt(2, "Propiedades Simulacion");
        this.tabPanel.setTitleAt(1, "Ajuste de Operadores");
        this.useChart.setSelected(true);
        this.statics.setSelected(true);
        enableStadistics();
        //set  data for the validators
        Component[] comps = cargaDatos.getComponents();
        for (int i = 0; i < comps.length; i++) {
            Component component = comps[i];
            if (component instanceof JSpinner) {
                spinnersCargaDatos.add((JSpinner) component);
            }
        }
        this.velocidad.setValue(10);

    }

    private void enableStadistics() {
        boolean value = statics.isSelected();
        Component[] comps = stadistic.getComponents();
        for (int i = 0; i < comps.length; i++) {
            Component component = comps[i];
            if (!component.equals(statics)) {
                component.setEnabled(value);
            }
        }
    }

    public void updateProgress(int progress) {
        this.jProgressBar1.setValue(progress);
    }
}
